package com.netty.demo4;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;

/**
 * Created by Lxk on 2019/5/1.
 */
public class MyServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if(evt instanceof IdleStateEvent){
            IdleStateEvent event = (IdleStateEvent) evt;
            String eventType = null;
            switch (event.state()){
                case WRITER_IDLE:
                    System.out.println("Write Event");
                    break;
                case READER_IDLE:
                    System.out.println("Read Event");
                    break;
                case ALL_IDLE:
                    System.out.println("All Event");
                    break;
            }
            ctx.channel().closeFuture();
        }
    }
}
